package reflect;

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;

public class Test1 {
    public static void main(String[] args) throws Exception {
        List<Person> list =new ArrayList<>();
        Class cls = Class.forName("reflect.Person");
        Constructor c=cls.getConstructor(String.class,int.class);
        for(int i=0;i<10;i++){
            String a= "test"+(i+1);
            int b= 21+i;
            Object obj = c.newInstance(a,b);
            System.out.println(obj);
            list.add((Person) obj);
        }
        System.out.println(list);
    }
}
